<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
    
    <style>
      .box {
        border: 1px gray solid;
        border-radius: 10px;
        padding: 15px;
      }
      
      .title {
        font-size: 15px;
        font-weight: bold;
        margin: 10px;
      }
      
      .card-parent {
        display: flex;
        flex-flow: column;
        row-gap: 10px;
      }
      
      .card {
        display: flex;
        column-gap: 10px;
      }
      
      .card-son {
        width: 200px;
        height: 50px;
        padding: 10px;
        margin: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
        color: darkgray;
        background: pink;
      }
    </style>
  </head>
  
  <body>
    <div id="app">
      <!-- in遍历，左侧遍历结果可为item / (item,index) / (item,key,index) / ({label},key,index) -->
      <div class="box">
        <div class="title">in遍历，左侧遍历结果可为item / (item,index) / (item,key,index) / ({label},key,index)</div>
        <div class="card">
          <div v-for="item in itemsNum" class="card-son">{{constant}} · {{item}}</div>
        </div>
      </div>
      <br>
      
      <!-- 遍历数据并解构 -->
      <div class="box">
        <div class="title">遍历数据并解构</div>
        <div class="card">
          <div v-for="({value},index) in itemsArr" class="card-son">{{index}} · {{value}}</div>
        </div>
      </div>
      <br>
      
      <!-- 嵌套遍历，遵循就近原则 -->
      <div class="box">
        <div class="title">嵌套遍历，遵循就近原则</div>
        <div class="card-parent">
          <div v-for="(item,indexArr) in itemsArr">
            <div class="card">
              <div v-for="(item,key,indexObj) in itemsObj" class="card-son">{{indexArr}} · {{indexObj}} · {{key}} · {{item}}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
  
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  
  <script>
    Vue.createApp({
      data() {
        return {
          // 试着修改以下属性值，看看HTML中的变化
          constant: '常量',
          itemsNum: 6,
          itemsArr: [
            {
              label: '一',
              value: 'One'
            },
            {
              label: '二',
              value: 'Two'
            },
            {
              label: '三',
              value: 'Three'
            },
            {
              label: '四',
              value: 'Four'
            },
            {
              label: '五',
              value: 'Five'
            },
            {
              label: '六',
              value: 'Six'
            },
          ],
          itemsObj: {
            one: '一',
            two: '二',
            three: '三',
            four: '四',
            five: '五',
            six: '六',
          },
        };
      },
    }).mount('#app');
  </script>
</html>